package com.example.work_02;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv=(TextView) findViewById(R.id.tv_01);
        Button btn01=(Button) findViewById(R.id.btn_01);
        Button btn02=(Button) findViewById(R.id.btn_02);
        Button btn03=( Button) findViewById(R.id.btn_03);
        Button btn04=(Button) findViewById(R.id.btn_04);
        Button btn05=(Button) findViewById(R.id.btn_05);
        Button btn06=(Button) findViewById(R.id.btn_06);
        btn06.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,SystemActivity.class);
                startActivity(intent);
            }
        });
        Button btn07=(Button) findViewById(R.id.btn_07);
        btn07.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,ProgressActivity.class);
                startActivity(intent);
            }
        });
        MyButtonlistener listener = new MyButtonlistener();
        btn01.setOnClickListener(MainActivity.this);
        btn02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tv.setText("点击了匿名内部类的监听器");
            }
        });
        btn04.setOnClickListener(listener);
        btn05.setOnClickListener(new BtnClickListener(this,tv));
        }
        public class MyButtonlistener implements View.OnClickListener{
        @Override
            public void onClick(View v){
            tv.setText("点击了内部类的监听器");
        }
        }
        public void btnClick(View view){
        tv.setText("点击了绑定标签的监听器");
        }
        @Override
    public void onClick(View v){
        tv.setText("点击了Activity监听器");
        }
    public class BtnClickListener implements View.OnClickListener{
        private Activity activity;
        private TextView textView;
        public BtnClickListener(Activity activity,TextView textView){
            this.activity=activity;
            this.textView=textView;
        }
        @Override
        public void onClick(View v){
            textView.setText("点击了外部监听器");
        }
    }
}
